function ShowOrHide(d1, d2)
{
	if (d1 != '') DoDiv(d1);
	if (d2 != '') DoDiv(d2);
}

function DoDiv(id)
{
	var item = null;
	if (document.getElementById) item = document.getElementById(id);
	else if (document.all) item = document.all[id];
	else if (document.layers) item = document.layers[id];
	if (!item) {}
	else if (item.style)
	{
		if (item.style.display == "none"){ item.style.display = ""; }
		else {item.style.display = "none"; }
	}
	else{ item.visibility = "show"; }
}


function insertag(opentag, closetag)
{
    var input = document.textarea.sendmessage;
    
    if (document.selection && typeof document.selection != 'undefined')
    {
        var str = document.selection.createRange().text;
        input.focus();
        
        var sel = document.selection.createRange();
        sel.text = "[" + opentag + "]" + str + "[/" + closetag + "]";
        sel.select();
        
        return;
    }
    else if (typeof input.selectionStart != 'undefined')
    {
        var start = input.selectionStart;
        var end = input.selectionEnd;
        var insText = input.value.substring(start, end);
        input.value = input.value.substr(0, start) + "[" + opentag + "]"
        + insText + "[/" + closetag + "]" + input.value.substr(end);
        input.focus();
        input.setSelectionRange(start + 2 + opentag.length + insText.length + 3
        + closetag.length, start + 2 + opentag.length + insText.length + 3 +
        closetag.length);
        return;
    }
    else
    {
        input.value += "[" + opentag + "][/" + closetag + "]";
        return;
    }
}


function insertext(text)
{
	document.textarea.sendmessage.focus();
    document.textarea.sendmessage.value = document.textarea.sendmessage.value
    + text;
    document.textarea.sendmessage.focus()
}

function show_emo(path)
{
        var emo_url = './' + path + '/' + document.add_emoticon.pic.options[document.add_emoticon.pic.selectedIndex].value;
        document.images.emoticon_preview.src = emo_url;
}